<template>
    <div>
        <van-sticky>
            <van-nav-bar title="修改密码" left-text="返回" left-arrow @click-left="onClickLeft" />
        </van-sticky>

        <van-form @submit="onSubmit">
            <van-field v-model="oldPassword" type="password" name="oldPassword" label="旧密码" placeholder="旧密码" />
            <van-field v-model="newPassword" type="password" name="newPassword" label="新密码" placeholder="新密码" />
            <div style="margin: 16px;">
                <van-button round block type="info" native-type="submit">修改</van-button>
            </div>
        </van-form>
    </div>
</template>
<script>
import { userReset } from "@/service/user/userLogin";
import nav from "@/mixin/nav"
export default {
    mixins: [nav],
    data() {
        return {
            oldPassword: "",
            newPassword: "",
        }
    },
    methods: {
        onClickLeft() {
            this.$router.go(-1);
        },
        async onSubmit() {
            let { data } = await userReset({
                oldPassword: this.oldPassword, newPassword: this.newPassword
            })
            console.log(data);
            if (data.code == 200) {
                this.$toast.success("密码修改成功!");
                this.$router.push("/mine");
            } else {
                this.$toast.fail(data.msg);
            }
        }
    }
}

</script>